<?php

class Core_Model_Article_Comment extends Dcmp_Model_Status {

    public function __construct() {
        parent::__construct();
        $this->tagType = 'article';
    }

    public function updateSupport(){
        Kd_Data_Factory::getUpdateDcl()
                        ->into('{t}article_comment')
                        ->value('support',':support:i')
                        ->eq('id', ':id:i')
                        ->addParameter(array('id' => $this->getId(), 'support'=>$this->getSupport()+1))
                        ->execute();
    }

    public function updateOpposition(){
        Kd_Data_Factory::getUpdateDcl()
                        ->into('{t}article_comment')
                        ->value('opposition',':opposition:i')
                        ->eq('id', ':id:i')
                        ->addParameter(array('id' => $this->getId(), 'opposition'=>$this->getOpposition()+1))
                        ->execute();
    }

    protected function initializeTable($table) {
        $table->setName('{t}article_comment');
        $table->createColumn('id', 'integer', TRUE, TRUE);
        $table->createColumn('detail', 'string');
        $table->createColumn('account', 'string');
        $table->createColumn('article_id', 'integer');
        $table->createColumn('time', 'string');
        $table->createColumn('support', 'integer');
        $table->createColumn('opposition', 'integer');
        $this->getTable()->createColumn('status', 'string');
        $this->getTable()->createColumn('status_message', 'string');
        $this->getTable()->createColumn('ip', 'string');
    }

}